'use strict';
exports = module.exports = function($scope, $state) {
    $scope.myDiagram = {};
    //插入内容
    var saveFilePathName = function(){return $state.current.url.replace(/.*\//g,'');}
    $scope.save = function () {
        $.ajax({
            url:"http://localhost:4010/writeFile",
            type:"post",
            data:{ code: $scope.myDiagram.model.toJson(), file: saveFilePathName() },
            success: function(res){ alert("ok") }
        });
    }
    $scope.load = function () {
        $.ajax({
            url:"http://localhost:4010/www/"+saveFilePathName()+".txt?time="+(+new Date),
            type:"get",
            success: function(res){
                $scope.myDiagram.model = go.Model.fromJson(res);
            }
        });
    }
}